/**
 * 产品树菜单
 * @authors supmain (mtingfeng@gmail.com)
 * @date    2015-01-17 10:46:15
 * @for 产品购买.html
 * @version $1.0$
 */
var consodesk = {
	log: function( msg ){
		if(window && window.console && window.console.log){
			console.log( msg );
		}
	},
	warn: function( msg ){
		if( window && window.console && window.console.warn ){
			console.warn( msg );
		}
	}
};
var BSTYUN = BSTYUN || {};
BSTYUN.zTree = {
	init: function( ){
		var that = this;
		that.navigatorToggle();
		
	},
	navigatorToggle: function( id ,typeName){
		var $happyPanel = $(".happyPanel") ;
		$happyPanel.happyTree();
	}
};
$(function(){
	BSTYUN.zTree.init( );
});
;(function( $ ){
	$.fn.extend( { happyTree: function(){
			this.each(function(){
				happyTree.call( this );
			});
		}
	});
	function happyTree( ){
		var $this = $( this ) ;
		$this.on( "click" , "a" ,function(){
			var _this = $( this ) ,
				  subitem = _this.next("ul") ,
				  hasnext = subitem.length == 0 ? false : true ,
				  othersitem = _this.parent().siblings().find( "ul" ) ;
			if( hasnext ){
				subitem.show( );
				othersitem.hide();
			}else{
				othersitem.hide();
			};
			
		} );
	};
	
})(jQuery);